{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "46d3fdd1a5fa4f51",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.351029Z",
     "start_time": "2024-02-19T01:47:20.662512Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1.0\n",
       "1    3.0\n",
       "2    5.0\n",
       "3    NaN\n",
       "4    6.0\n",
       "5    8.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np # linear algebra\n",
    "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
    "\n",
    "s = pd.Series([1, 3, 5, np.nan, 6, 8])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e745ca0fc931006e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.374060Z",
     "start_time": "2024-02-19T01:47:22.356696Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
       "               '2013-01-05', '2013-01-06'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dates = pd.date_range(\"20130101\", periods=6)\n",
    "dates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2757258a576616ab",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.428963Z",
     "start_time": "2024-02-19T01:47:22.377206Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.474680</td>\n",
       "      <td>-0.296923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>-0.290780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.568912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.295544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>-1.345345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.091111</td>\n",
       "      <td>-0.642097</td>\n",
       "      <td>2.507524</td>\n",
       "      <td>-0.514559</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.271155  2.440692 -0.474680 -0.296923\n",
       "2013-01-02  0.486849 -0.837350  0.689640 -0.290780\n",
       "2013-01-03 -1.449033 -0.732503  0.551999 -0.568912\n",
       "2013-01-04 -1.988569 -0.564089 -0.847413 -0.295544\n",
       "2013-01-05 -0.614300  0.580035 -0.345509 -1.345345\n",
       "2013-01-06  0.091111 -0.642097  2.507524 -0.514559"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list(\"ABCD\"))\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a838f06d7448fabe",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.458622Z",
     "start_time": "2024-02-19T01:47:22.433294Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A          float64\n",
       "B    datetime64[s]\n",
       "C          float32\n",
       "D            int32\n",
       "E         category\n",
       "F           object\n",
       "dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.DataFrame(\n",
    "    {\n",
    "        \"A\": 1.0,\n",
    "        \"B\": pd.Timestamp(\"20130102\"),\n",
    "        \"C\": pd.Series(1, index=list(range(4)), dtype=\"float32\"),\n",
    "        \"D\": np.array([3] * 4, dtype=\"int32\"),\n",
    "        \"E\": pd.Categorical([\"test\", \"train\", \"test\", \"train\"]),\n",
    "        \"F\": \"foo\",\n",
    "    }\n",
    ")\n",
    "df2\n",
    "df2.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "74a9f132d888b50a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.494109Z",
     "start_time": "2024-02-19T01:47:22.463974Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.474680</td>\n",
       "      <td>-0.296923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>-0.290780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.568912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.295544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>-1.345345</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.271155  2.440692 -0.474680 -0.296923\n",
       "2013-01-02  0.486849 -0.837350  0.689640 -0.290780\n",
       "2013-01-03 -1.449033 -0.732503  0.551999 -0.568912\n",
       "2013-01-04 -1.988569 -0.564089 -0.847413 -0.295544\n",
       "2013-01-05 -0.614300  0.580035 -0.345509 -1.345345"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9f28505e88af4217",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.526618Z",
     "start_time": "2024-02-19T01:47:22.503097Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.295544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>-1.345345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.091111</td>\n",
       "      <td>-0.642097</td>\n",
       "      <td>2.507524</td>\n",
       "      <td>-0.514559</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-04 -1.988569 -0.564089 -0.847413 -0.295544\n",
       "2013-01-05 -0.614300  0.580035 -0.345509 -1.345345\n",
       "2013-01-06  0.091111 -0.642097  2.507524 -0.514559"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e497020670e78df9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.543425Z",
     "start_time": "2024-02-19T01:47:22.529842Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
       "               '2013-01-05', '2013-01-06'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "947c044f850513cf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.565275Z",
     "start_time": "2024-02-19T01:47:22.545575Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C', 'D'], dtype='object')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a77a2ea9d5725643",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.591381Z",
     "start_time": "2024-02-19T01:47:22.572257Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.2711548 ,  2.44069193, -0.47468028, -0.29692347],\n",
       "       [ 0.48684931, -0.83735037,  0.68964016, -0.29078035],\n",
       "       [-1.44903309, -0.73250295,  0.55199866, -0.56891207],\n",
       "       [-1.98856907, -0.56408905, -0.84741302, -0.29554415],\n",
       "       [-0.6142995 ,  0.58003512, -0.34550932, -1.34534491],\n",
       "       [ 0.09111094, -0.64209719,  2.50752384, -0.51455915]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ebea57d9474a0bcf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.613719Z",
     "start_time": "2024-02-19T01:47:22.594656Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A          float64\n",
       "B    datetime64[s]\n",
       "C          float32\n",
       "D            int32\n",
       "E         category\n",
       "F           object\n",
       "dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3efce986e6d8f52b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.643185Z",
     "start_time": "2024-02-19T01:47:22.618750Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.0, Timestamp('2013-01-02 00:00:00'), 1.0, 3, 'test', 'foo'],\n",
       "       [1.0, Timestamp('2013-01-02 00:00:00'), 1.0, 3, 'train', 'foo'],\n",
       "       [1.0, Timestamp('2013-01-02 00:00:00'), 1.0, 3, 'test', 'foo'],\n",
       "       [1.0, Timestamp('2013-01-02 00:00:00'), 1.0, 3, 'train', 'foo']],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "cbd137ce620cdaf7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.694720Z",
     "start_time": "2024-02-19T01:47:22.655240Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>-0.624183</td>\n",
       "      <td>0.040781</td>\n",
       "      <td>0.346927</td>\n",
       "      <td>-0.552011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.939435</td>\n",
       "      <td>1.284651</td>\n",
       "      <td>1.217263</td>\n",
       "      <td>0.407469</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-1.345345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-1.240350</td>\n",
       "      <td>-0.709902</td>\n",
       "      <td>-0.442388</td>\n",
       "      <td>-0.555324</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>-0.442727</td>\n",
       "      <td>-0.603093</td>\n",
       "      <td>0.103245</td>\n",
       "      <td>-0.405741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.000545</td>\n",
       "      <td>0.294004</td>\n",
       "      <td>0.655230</td>\n",
       "      <td>-0.295889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>2.507524</td>\n",
       "      <td>-0.290780</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              A         B         C         D\n",
       "count  6.000000  6.000000  6.000000  6.000000\n",
       "mean  -0.624183  0.040781  0.346927 -0.552011\n",
       "std    0.939435  1.284651  1.217263  0.407469\n",
       "min   -1.988569 -0.837350 -0.847413 -1.345345\n",
       "25%   -1.240350 -0.709902 -0.442388 -0.555324\n",
       "50%   -0.442727 -0.603093  0.103245 -0.405741\n",
       "75%    0.000545  0.294004  0.655230 -0.295889\n",
       "max    0.486849  2.440692  2.507524 -0.290780"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8f7cf10b1e71d8ee",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.739774Z",
     "start_time": "2024-02-19T01:47:22.696872Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2013-01-01</th>\n",
       "      <th>2013-01-02</th>\n",
       "      <th>2013-01-03</th>\n",
       "      <th>2013-01-04</th>\n",
       "      <th>2013-01-05</th>\n",
       "      <th>2013-01-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>0.486849</td>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.091111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.642097</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>-0.474680</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>2.507524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>-0.296923</td>\n",
       "      <td>-0.290780</td>\n",
       "      <td>-0.568912</td>\n",
       "      <td>-0.295544</td>\n",
       "      <td>-1.345345</td>\n",
       "      <td>-0.514559</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   2013-01-01  2013-01-02  2013-01-03  2013-01-04  2013-01-05  2013-01-06\n",
       "A   -0.271155    0.486849   -1.449033   -1.988569   -0.614300    0.091111\n",
       "B    2.440692   -0.837350   -0.732503   -0.564089    0.580035   -0.642097\n",
       "C   -0.474680    0.689640    0.551999   -0.847413   -0.345509    2.507524\n",
       "D   -0.296923   -0.290780   -0.568912   -0.295544   -1.345345   -0.514559"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ebafdad27fb4605",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.782098Z",
     "start_time": "2024-02-19T01:47:22.748594Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>D</th>\n",
       "      <th>C</th>\n",
       "      <th>B</th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.296923</td>\n",
       "      <td>-0.474680</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.271155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.290780</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>0.486849</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-0.568912</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>-1.449033</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-0.295544</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>-1.988569</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.345345</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.614300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>-0.514559</td>\n",
       "      <td>2.507524</td>\n",
       "      <td>-0.642097</td>\n",
       "      <td>0.091111</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   D         C         B         A\n",
       "2013-01-01 -0.296923 -0.474680  2.440692 -0.271155\n",
       "2013-01-02 -0.290780  0.689640 -0.837350  0.486849\n",
       "2013-01-03 -0.568912  0.551999 -0.732503 -1.449033\n",
       "2013-01-04 -0.295544 -0.847413 -0.564089 -1.988569\n",
       "2013-01-05 -1.345345 -0.345509  0.580035 -0.614300\n",
       "2013-01-06 -0.514559  2.507524 -0.642097  0.091111"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_index(axis=1, ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b6052f1d004e2f97",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.809939Z",
     "start_time": "2024-02-19T01:47:22.785938Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>-0.290780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.568912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.091111</td>\n",
       "      <td>-0.642097</td>\n",
       "      <td>2.507524</td>\n",
       "      <td>-0.514559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "      <td>-0.847413</td>\n",
       "      <td>-0.295544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.580035</td>\n",
       "      <td>-0.345509</td>\n",
       "      <td>-1.345345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.474680</td>\n",
       "      <td>-0.296923</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-02  0.486849 -0.837350  0.689640 -0.290780\n",
       "2013-01-03 -1.449033 -0.732503  0.551999 -0.568912\n",
       "2013-01-06  0.091111 -0.642097  2.507524 -0.514559\n",
       "2013-01-04 -1.988569 -0.564089 -0.847413 -0.295544\n",
       "2013-01-05 -0.614300  0.580035 -0.345509 -1.345345\n",
       "2013-01-01 -0.271155  2.440692 -0.474680 -0.296923"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by=\"B\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "8fa03d236c8c414d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.826527Z",
     "start_time": "2024-02-19T01:47:22.815427Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2013-01-01   -0.271155\n",
       "2013-01-02    0.486849\n",
       "2013-01-03   -1.449033\n",
       "2013-01-04   -1.988569\n",
       "2013-01-05   -0.614300\n",
       "2013-01-06    0.091111\n",
       "Freq: D, Name: A, dtype: float64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"A\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "eb3e403938647ad7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.857111Z",
     "start_time": "2024-02-19T01:47:22.829796Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>2.440692</td>\n",
       "      <td>-0.474680</td>\n",
       "      <td>-0.296923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "      <td>0.689640</td>\n",
       "      <td>-0.290780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "      <td>0.551999</td>\n",
       "      <td>-0.568912</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.271155  2.440692 -0.474680 -0.296923\n",
       "2013-01-02  0.486849 -0.837350  0.689640 -0.290780\n",
       "2013-01-03 -1.449033 -0.732503  0.551999 -0.568912"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f795d40eade5d4de",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.884551Z",
     "start_time": "2024-02-19T01:47:22.862858Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2013-01-01 00:00:00\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "A   -0.271155\n",
       "B    2.440692\n",
       "C   -0.474680\n",
       "D   -0.296923\n",
       "Name: 2013-01-01 00:00:00, dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(dates[0])\n",
    "df.loc[dates[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "54c41c889d47a18f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.907822Z",
     "start_time": "2024-02-19T01:47:22.888941Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.271155</td>\n",
       "      <td>2.440692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.614300</td>\n",
       "      <td>0.580035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.091111</td>\n",
       "      <td>-0.642097</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B\n",
       "2013-01-01 -0.271155  2.440692\n",
       "2013-01-02  0.486849 -0.837350\n",
       "2013-01-03 -1.449033 -0.732503\n",
       "2013-01-04 -1.988569 -0.564089\n",
       "2013-01-05 -0.614300  0.580035\n",
       "2013-01-06  0.091111 -0.642097"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[:, [\"A\", \"B\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "24a291b60d8b7ac3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.945334Z",
     "start_time": "2024-02-19T01:47:22.910368Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>0.486849</td>\n",
       "      <td>-0.837350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-1.449033</td>\n",
       "      <td>-0.732503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>-1.988569</td>\n",
       "      <td>-0.564089</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B\n",
       "2013-01-02  0.486849 -0.837350\n",
       "2013-01-03 -1.449033 -0.732503\n",
       "2013-01-04 -1.988569 -0.564089"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\"20130102\":\"20130104\", [\"A\", \"B\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2b4bbb655e87709f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.968751Z",
     "start_time": "2024-02-19T01:47:22.947542Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.2711547957043029"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[dates[0], \"A\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6627f62ffcea1d0e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:22.995339Z",
     "start_time": "2024-02-19T01:47:22.973172Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Среднее значение для каждого столбца\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "A   -0.624183\n",
       "B    0.040781\n",
       "C    0.346927\n",
       "D   -0.552011\n",
       "dtype: float64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"Среднее значение для каждого столбца\")\n",
    "df.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "78bf70e409bdacc8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:23.024853Z",
     "start_time": "2024-02-19T01:47:22.997488Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2013-01-01    0.349483\n",
       "2013-01-02    0.012090\n",
       "2013-01-03   -0.549612\n",
       "2013-01-04   -0.923904\n",
       "2013-01-05   -0.431280\n",
       "2013-01-06    0.360495\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.mean(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "bdff057298507e59",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:23.050044Z",
     "start_time": "2024-02-19T01:47:23.028067Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAA</th>\n",
       "      <th>BBB</th>\n",
       "      <th>CCC</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>20</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6</td>\n",
       "      <td>30</td>\n",
       "      <td>-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>40</td>\n",
       "      <td>-50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   AAA  BBB  CCC\n",
       "0    4   10  100\n",
       "1    5   20   50\n",
       "2    6   30  -30\n",
       "3    7   40  -50"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({\"AAA\": [4, 5, 6, 7], \"BBB\": [10, 20, 30, 40], \"CCC\": [100, 50, -30, -50]})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "55c8b2b1f0562889",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:23.111319Z",
     "start_time": "2024-02-19T01:47:23.068761Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAA</th>\n",
       "      <th>BBB</th>\n",
       "      <th>CCC</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>-1</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6</td>\n",
       "      <td>-1</td>\n",
       "      <td>-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>-1</td>\n",
       "      <td>-50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   AAA  BBB  CCC\n",
       "0    4   10  100\n",
       "1    5   -1   50\n",
       "2    6   -1  -30\n",
       "3    7   -1  -50"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df.AAA >= 5, \"BBB\"] = -1\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "db86496571f07a09",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:23.175233Z",
     "start_time": "2024-02-19T01:47:23.121839Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAA</th>\n",
       "      <th>BBB</th>\n",
       "      <th>CCC</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>555</td>\n",
       "      <td>555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6</td>\n",
       "      <td>555</td>\n",
       "      <td>555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>555</td>\n",
       "      <td>555</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   AAA  BBB  CCC\n",
       "0    4   10  100\n",
       "1    5  555  555\n",
       "2    6  555  555\n",
       "3    7  555  555"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df.AAA >= 5, [\"BBB\", \"CCC\"]] = 555\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d8909ab66c5016ab",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-19T01:47:23.184355Z",
     "start_time": "2024-02-19T01:47:23.178991Z"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
